Packet-transfer devices in high-speed data networks, such as switches and routers, are required to perform flexible and sophisticated packet classification at high speed. For this purpose, many switches and routers use ternary content-addressable memory (TCAM) components to store rules that are to be applied in processing packets. To search the TCAM, several fields of the packet (typically header fields) are concatenated to form a key. A match between the key and a given TCAM entry can be used to trigger various actions for application by the network device, such as forwarding decisions, packet encapsulation and de-capsulation, security filtering, and quality of service classification.
TCAM is advantageous in that it is able to hold search entries that contain not only ones and zeroes, to be matched against the key, but also “don't care” bits, which will match either a zero or a one in the key. These “don't care” bits in the TCAM entries are commonly referred to as “masked” bits, while bits having a defined value (1 or 0) are referred to as “unmasked.” TCAM thus affords a high degree of flexibility in rule definition. As against these advantages, however, TCAMs are costly in terms of power consumption and chip area, and these costs effectively limit the number of rules that can be supported by a single network device.